package java_class_work.week03.NoneNameClassDemo;

/**
 * 匿名内部类
 */
abstract class Speak {
    public abstract void speak_hello();
}

class Student {
    void fun(Speak sp) {
        sp.speak_hello();
    }
}

public class Demo01 {
    public static void main(String[] args) {
        Speak speak = new Speak() {
            @Override
            public void speak_hello() {
                System.out.println("Hello");
            }
        };
        speak.speak_hello();

        Student student = new Student();
        student.fun(new Speak() {
            @Override
            public void speak_hello() {
                System.out.println("Student say: Hello");
            }
        });
    }
}
